<?php include ('db_info.php'); ?>
<?php include ('db_funcs.php'); ?>

<?
	$orders_str="";
	$values_str="";
	$i=0;
	
	foreach ($_POST as $name=>$value)
	{
		if ($name !="action")
		{
			if ($i==0)
			{
				$orders_str=$name;
				if(strtolower($value) == 'null')
					$values_str=$value;
				else
					$values_str="'".$value."'";
			}
			else
			{					
				$orders_str.=", ".$name;
				if(strtolower($value) == 'null')
					$values_str.=", ".$value."";
				else
					$values_str.=", '".$value."'";
			}
			$i++;
		}
	}




		
	$host = $_SERVER[HTTP_HOST];
		
	if(!preg_match('/^www\./',$host))
		$host = 'www.'.$host;
	
	$sql="insert into orders(".$orders_str.", create_time, create_date, site) values(".$values_str.", ".time().", '".date("Ymd",time())."', '".$host."')";
		
	file_put_contents ( 'request_sp_log.txt' , '['.date('Y-m-d H:i:s').'] '.$sql."\n",FILE_APPEND | LOCK_EX);
	
	queryWithExit($GLOBALS['mysqli_conn1'],$sql);
	
	echo 'ok';
?>
